import request from '@/utils/request'
import { status } from 'nprogress'

const api_name = '/student'//controller层的父目录

export default {
   

    //获取某个学生参加的竞赛
    getPageList(current,limit,searchObj){//可以看后端这个接口第三个参数被@RequestBody修饰，所以这里传入data
        return request({
            url: `/stucom/listCom/${current}/${limit}`,
            //无分页的时候用get就可以，但是有分页的时候用post请求，因为后端那无分页是@GetMapping,有分页是@PostMapping,
            //必须对应上，因为分页用到了@RequestBody，必须是post请求
            method: 'post',
            data:searchObj,//做模糊查询
          })
    },
   
    //发布竞赛
    addCom(com){
        return request({
            url:`${api_name}/addCom`,
            method:'post',
            data:com //hospSet作为json对象传给后端
        })
    },

    //学生报名参赛
    addStuCom(com){
        return request({
            url:`/stucom/addStuCom`,
            method:'post',
            data:com //hospSet作为json对象传给后端
        })
    },

     //删除竞赛
     deleteCom(id){
        return request({
            url:`${api_name}/deleteCom/${id}`,
            method:"post",
        })
    },
    //根据id查询竞赛设置
    getCom(id){
        return request({
            url:`${api_name}/getCom/${id}`,
            method:'GET'
        })
    },
    //修改竞赛设置
    updatedCom(com) {
        return request({
            url:`${api_name}/updateCom`,
            method:'put',
            data:com
        })
    },

    //注册
    register(stu){
        return request({
            url:`${api_name}/register`,
            method:'post',
            data:stu //hospSet作为json对象传给后端
        })
    },

    //获取当前用户
    getUser(){
        return request({
            url:`${api_name}/getCurrentUser`,
            method:'post'
        })
    },

    //修改个人信息
    updateAccount(stu){
        return request({
            url:`${api_name}/updateAccount`,
            method:'post',
            data:stu //hospSet作为json对象传给后端
        })
    },
}